package com.tuozixuan.camel.remove;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class RemoveDemoRoute extends RouteBuilder {

	@Override
	public void configure() {
	    
	    // 移除一个指定的头信息
//	    from("timer:firedOnceTimer?repeatCount=1")
//	    .setHeader("Custom-Info", ()-> "this is custom header")
//	    .removeHeader("Custom-Info")
//	    .setBody(simple("Custom-Info:${header.Custom-Info}"))
//	    .to("stream:out");
	    
	    // 移除以Custom开头的头信息
//        from("timer:firedOnceTimer?repeatCount=1")
//        .setHeader("Custom-Info", ()-> "this is custom header")
//        .setHeader("Custom-Info1", ()-> "this is custom header1")
//        .setHeader("Custom-Info2", ()-> "this is custom header2")
//        .setHeader("My-Name", ()-> "this is my name header")
//        .removeHeaders("Custom-Info*")
//        .setBody(simple("Custom-Info:${header.Custom-Info} My-Name:${header.My-Name}"))
//        .to("stream:out");
	    
	    // 移除以Custom开头的头信息，但不移除以Custom-Info2开头的头信息
//        from("timer:firedOnceTimer?repeatCount=1")
//        .setHeader("Custom-Info", ()-> "this is custom header")
//        .setHeader("Custom-Info1", ()-> "this is custom header1")
//        .setHeader("Custom-Info2", ()-> "this is custom header2")
//        .setHeader("My-Name", ()-> "this is my name header")
//        .removeHeaders("Custom-Info*", "Custom-Info2*")
//        .setBody(simple("Custom-Info2:${header.Custom-Info2} My-Name:${header.My-Name}"))
//        .to("stream:out");
        
	    // 使用正则表达式移除头信息
//        from("timer:firedOnceTimer?repeatCount=1")
//        .setHeader("Custom-Info", ()-> "this is custom header")
//        .setHeader("Custom-Info1", ()-> "this is custom header1")
//        .setHeader("Custom-Info2", ()-> "this is custom header2")
//        .setHeader("My-Name", ()-> "this is my name header")
//        .removeHeaders("Custom-Info[0-9]")
//        .setBody(simple("Custom-Info2:${header.Custom-Info2} My-Name:${header.My-Name}"))
//        .to("stream:out");
	    
	    // 根据属性名移除指定的属性
//        from("timer:firedOnceTimer?repeatCount=1")
//        .setProperty("Custom-Info", ()-> "this is custom Property")
//        .setProperty("Custom-Info1", ()-> "this is custom Property1")
//        .setProperty("Custom-Info2", ()-> "this is custom Property2")
//        .setProperty("My-Name", ()-> "this is my name header")
//        .removeProperty("Custom-Info")
//        .setBody(simple("Custom-Info:${exchangeProperty.Custom-Info} My-Name:${exchangeProperty.My-Name}"))
//        .to("stream:out");
        
	    // 使用通配符移除所有的属性
//        from("timer:firedOnceTimer?repeatCount=1")
//        .setProperty("Custom-Info", ()-> "this is custom Property")
//        .setProperty("Custom-Info1", ()-> "this is custom Property1")
//        .setProperty("Custom-Info2", ()-> "this is custom Property2")
//        .setProperty("My-Name", ()-> "this is my name header")
//        .removeProperties("*")
//        .setBody(simple("Custom-Info:${exchangeProperty.Custom-Info} My-Name:${exchangeProperty.My-Name}"))
//        .to("stream:out");
        
        // 使用通配符移除以Custom-Info开始的属性
//        from("timer:firedOnceTimer?repeatCount=1")
//        .setProperty("Custom-Info", ()-> "this is custom Property")
//        .setProperty("Custom-Info1", ()-> "this is custom Property1")
//        .setProperty("Custom-Info2", ()-> "this is custom Property2")
//        .setProperty("My-Name", ()-> "this is my name header")
//        .removeProperties("Custom-Info*")
//        .setBody(simple("Custom-Info:${exchangeProperty.Custom-Info} My-Name:${exchangeProperty.My-Name}"))
//        .to("stream:out");
        
        // 使用正则表达式移除
//        from("timer:firedOnceTimer?repeatCount=1")
//        .setProperty("Custom-Info", ()-> "this is custom Property")
//        .setProperty("Custom-Info1", ()-> "this is custom Property1")
//        .setProperty("Custom-Info2", ()-> "this is custom Property2")
//        .setProperty("My-Name", ()-> "this is my name header")
//        .removeProperties("Custom-Info[0-9]?")
//        .setBody(simple("Custom-Info:${exchangeProperty.Custom-Info} My-Name:${exchangeProperty.My-Name}"))
//        .to("stream:out");

	}

}
